
[dbo].[vSoaInvoiceLineAR]
CREATE VIEW [dbo].[vSoaInvoiceLineAR]
AS
SELECT il.InvoiceLineId,
il.InvoiceId,
il.LineNumber,
il.ItemId,
il.ShipToPartyId,
il.Quantity,
il.UnitPrice,
il.ExtendedAmount,
il.PaymentAdjustmentAmount,
ISNULL(pp.[Amount],0) AS PendingPaymentAdjustmentAmount,
(il.ExtendedAmount - il.PaymentAdjustmentAmount - ISNULL(pp.[Amount],0)) AS Balance,
CAST(null AS datetime) BILL_DATE
FROM [dbo].[vSoaInvoiceLineARBase] il
LEFT JOIN [dbo].[vSoaPendingARPaymentAdjustment] pp ON il.[REFERENCE_NUM] = pp.[INVOICE_REFERENCE_NUM] AND il.[LineNumber] = pp.[INVOICE_LINE_NUM]
GO